<template>
    <div class="table">
        
        <el-table
            ref="table"
            :data="tableData"
            style="width:100%"
            border
            @selection-change="selectMoreChange"
        >
            <el-table-column
                type="selection"
                width="55"
                v-if="ifSelection"
               
            ></el-table-column>

            <el-table-column
                type="index"
            >
            </el-table-column>

            <el-table-column
                prop="infoName"
                label="资料名称"
            >
            </el-table-column>

            <el-table-column
                label="信息所属"
                prop="belongLabel"
            >
            </el-table-column>

            <el-table-column
                prop="infoTypeLabel"
                label="资料类型"
            >
            </el-table-column>

            <el-table-column
                prop="chooseValueString"
                label="可选值"
            >
            </el-table-column>

            <el-table-column
                label="证件图片"
            >
                <template slot-scope="scope">
                    <span class="iconfont" :class="scope.row.iconName" style="font-size: .6rem"></span>
                </template>
            </el-table-column>

            <el-table-column
                label="操作"
            >
                <template slot-scope="scope">
                    <el-button type="text" size="mini" @click="showChange(scope.$index)">修改</el-button>
                    <el-button type="text" size="mini" @click="delCertifyNeed(scope.$index)">删除</el-button>
                </template>
            </el-table-column>


        </el-table>
    </div>
</template>

<script>
export default {
    name: 'Table',
    props: {
        tableData: Array,
        ifSelection: Boolean
    },
    data () {
        return {
            selectMore: []
        }
    },
    methods: {
        resetSelectMore () {
            this.selectMore = [];
            this.$refs.table.clearSelection();
        },
        selectMoreChange (val) {
            this.selectMore = val;
        },
        delCertifyNeed (index) {
            if (this.tableData[index].infoName === '认证分类') {
                this.$message({
                    message: '不可删除!',
                    type: 'warning'
                })
                return;
            }
            this.$confirm('确认删除？', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                this.$emit('delCertifyNeed', index);
            }).catch(() => {
                this.$message({
                    message: '已取消删除',
                    type: 'info'
                })
            })
        },
        showChange (index) {
            if (this.tableData[index].infoName === '认证分类') {
                this.$message({
                    message: '不可更改!',
                    type: 'warning'
                })
                return;
            }
            this.$emit('showChange', index);
        }
    }
}
</script>

<style lang="stylus" scoped>
    .table
        width 100%
        height 100%
</style>

